package com.douxg.fastCoding.enjoy.source;

import com.douxg.fastCoding.web.entity.Enjoy;
import com.jfinal.template.source.ISource;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Description mysql数据库模板来源
 * @Auther douxg
 * @Date 2020/5/11 23:43
 */
@Data
@Accessors(chain = true)
public class MysqlEnjoySource implements ISource {
    private String encoding = "utf-8";
    private boolean modify = false;
    private Enjoy enjoy;

    @Override
    public boolean isModified() {
        return modify;
    }

    @Override
    public String getCacheKey() {
        Long id = this.enjoy.getId();
        return id == null ? null : id + "";
    }

    @Override
    public StringBuilder getContent() {
        String content = this.enjoy.getContent();
        if (content != null) {
            return new StringBuilder(content);
        }
        return null;
    }

    @Override
    public String getEncoding() {
        return this.encoding;
    }
}
